home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Cursor;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.Vector;
-
- public class ScrollUpDown extends Applet implements Runnable, MouseListener {
- private Thread thread;
- // $FF: renamed from: b java.awt.Graphics
- private Graphics field_0;
- private Image buffer;
- private boolean loaded;
- private boolean paintable = false;
- private boolean move = true;
- private boolean firstime = true;
- // $FF: renamed from: on boolean
- private boolean field_1 = true;
- // $FF: renamed from: wi int
- private int field_2;
- // $FF: renamed from: he int
- private int field_3;
- private int decx;
- private int pause;
- private int heightSpace;
- private int textHeight;
- private Color textColor;
- private Color backColor;
- private int wiBack;
- private int heBack;
- private Color enterBackColor;
- private AudioClip sound;
- private AudioClip clicSound;
- private AudioClip enterSound;
- private boolean loopSound;
- private String link;
- private String statusBarText;
- private String text;
- private Image textImage;
- private int textImageHeight;
- // $FF: renamed from: Y int
- private int field_4;
- private int YStep;
- private int direction;
- private boolean freeze = false;
- private int pause2;
-
- public String getAppletInfo() {
- return "Name: ScrollUpDown\r\nAuthor: Taiji Software\r\n";
- }
-
- public ScrollUpDown() {
- this.move = true;
- this.pause = 100;
- this.heightSpace = 15;
- this.decx = 10;
- this.textHeight = 20;
- this.YStep = 2;
- this.direction = 1;
- this.pause2 = 3000;
- ((Component)this).addMouseListener(this);
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var9) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- if (this.sound != null) {
- if (this.loopSound) {
- this.sound.loop();
- return;
- }
-
- this.sound.play();
- }
-
- }
-
- public void getParameters() {
- String s = ((Applet)this).getParameter("pause");
- if (s != null) {
- this.pause = Integer.parseInt(s);
- }
-
- this.field_2 = ((Component)this).getSize().width;
- this.field_3 = ((Component)this).getSize().height;
- this.text = ((Applet)this).getParameter("text");
- this.textColor = this.getColor("text_color");
- this.backColor = this.getColor("background_color");
- ((Component)this).setBackground(this.backColor);
- s = ((Applet)this).getParameter("height_space");
- if (s != null) {
- this.heightSpace = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("text_height");
- if (s != null) {
- this.textHeight = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("width_shift");
- if (s != null) {
- this.decx = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("text_step");
- if (s != null) {
- this.YStep = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("direction");
- if (s != null && s.equals("down")) {
- this.direction = -1;
- }
-
- this.statusBarText = ((Applet)this).getParameter("status_bar_text");
- s = ((Applet)this).getParameter("sound_name");
- if (s != null) {
- this.sound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("loop_sound");
- if (s != null) {
- if (s.equals("yes")) {
- this.loopSound = true;
- } else {
- this.loopSound = false;
- }
- }
-
- s = ((Applet)this).getParameter("clic_sound_name");
- if (s != null) {
- this.clicSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("enter_sound_name");
- if (s != null) {
- this.enterSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- this.link = ((Applet)this).getParameter("link");
- s = ((Applet)this).getParameter("on_click_pause");
- if (s != null) {
- if (s.equals("yes")) {
- this.freeze = true;
- } else {
- this.freeze = false;
- }
- }
-
- s = ((Applet)this).getParameter("pause2");
- if (s != null) {
- this.pause2 = Integer.parseInt(s);
- }
-
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public final void paint(Graphics g) {
- if (this.paintable) {
- this.field_0.clearRect(0, 0, this.field_2, this.field_3);
- this.field_0.drawImage(this.textImage, 0, this.field_4, this);
- g.drawImage(this.buffer, 0, 0, this);
- }
-
- }
-
- public final void update(Graphics g) {
- this.paint(g);
- }
-
- public void start() {
- this.move = true;
- if (this.thread == null) {
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- }
-
- public void stop() {
- if (this.thread != null) {
- this.move = false;
- this.thread = null;
- }
-
- if (this.sound != null) {
- this.sound.stop();
- }
-
- }
-
- public void run() {
- if (this.firstime) {
- this.buffer = ((Component)this).createImage(this.field_2, this.field_3);
- this.field_0 = this.buffer.getGraphics();
- String fontName = ((Applet)this).getParameter("text_font");
- if (fontName == null) {
- fontName = "TimesRoman";
- }
-
- int style = 1;
- String s = ((Applet)this).getParameter("text_style");
- if (s != null) {
- if (s.equals("bold")) {
- style = 1;
- } else if (s.equals("italic")) {
- style = 2;
- } else if (s.equals("bold_italic")) {
- style = 3;
- } else {
- style = 0;
- }
- }
-
- int m = 0;
- int c = 0;
- if (this.text != null) {
- while((c = this.text.indexOf("#", c)) != -1) {
- ++c;
- ++m;
- }
- } else {
- BufferedReader br = null;
- String filename = ((Applet)this).getParameter("filename");
- if (filename == null) {
- System.out.println("Error: Text file not found !");
- return;
- }
-
- try {
- br = new BufferedReader(new InputStreamReader((new URL(((Applet)this).getCodeBase(), filename)).openStream()));
- } catch (Exception e2) {
- System.out.println(e2);
- }
-
- s = "";
- this.field_0.setFont(new Font(fontName, style, this.textHeight));
- FontMetrics fm = this.field_0.getFontMetrics();
-
- try {
- while((s = br.readLine()) != null) {
- m += this.warp(s, fm).length;
- }
- } catch (IOException ex3) {
- System.out.println(ex3);
- }
- }
-
- this.textImageHeight = (m + 1) * (this.textHeight + this.heightSpace) + this.heightSpace;
- this.textImage = ((Component)this).createImage(this.field_2, this.textImageHeight);
- Graphics e = this.textImage.getGraphics();
- e.setFont(new Font(fontName, style, this.textHeight));
- e.setColor(this.textColor);
- int hPos = this.textHeight;
- if (this.text != null) {
- if (m != 0) {
- int[] index = new int[m];
- m = 0;
-
- FontMetrics fm;
- for(fm = e.getFontMetrics(); (c = this.text.indexOf("#", c)) != -1; ++m) {
- index[m] = c;
- String line;
- if (m == 0) {
- line = this.text.substring(0, index[0]);
- } else {
- line = this.text.substring(index[m - 1] + 1, index[m]);
- }
-
- int x = this.decx;
- if (this.decx == -1) {
- x = (this.field_2 - fm.stringWidth(line)) / 2;
- }
-
- e.drawString(line, x, hPos);
- hPos += this.textHeight + this.heightSpace;
- ++c;
- }
-
- String line = this.text.substring(index[m - 1] + 1);
- int x = this.decx;
- if (this.decx == -1) {
- x = (this.field_2 - fm.stringWidth(line)) / 2;
- }
-
- e.drawString(line, x, hPos);
- } else {
- e.drawString(this.text, this.decx, hPos);
- }
- } else {
- BufferedReader br = null;
- String filename = ((Applet)this).getParameter("filename");
- if (filename == null) {
- System.out.println("Error: Text file not found !");
- return;
- }
-
- try {
- br = new BufferedReader(new InputStreamReader((new URL(((Applet)this).getCodeBase(), filename)).openStream()));
- } catch (Exception e2) {
- System.out.println(e2);
- }
-
- s = "";
-
- try {
- FontMetrics fm = e.getFontMetrics();
-
- while((s = br.readLine()) != null) {
- String[] str = this.warp(s, fm);
-
- for(int i = 0; i < str.length; ++i) {
- int x = this.decx;
- if (this.decx == -1) {
- x = (this.field_2 - fm.stringWidth(str[i])) / 2;
- }
-
- e.drawString(str[i], x, hPos);
- hPos += this.textHeight + this.heightSpace;
- }
- }
- } catch (IOException ex3) {
- System.out.println(ex3);
- }
- }
-
- e.dispose();
- this.firstime = false;
- this.paintable = true;
- }
-
- if (this.direction == -1) {
- this.field_4 = -this.textImageHeight;
- } else {
- this.field_4 = this.field_3;
- }
-
- while(this.move) {
- while(this.field_1) {
- do {
- ((Component)this).repaint();
- if (this.direction == -1) {
- this.field_4 += this.YStep;
- if (this.field_4 > this.field_3) {
- this.field_4 = -this.textImageHeight;
- if (this.pause2 == -1) {
- return;
- }
-
- try {
- Thread.sleep((long)this.pause2);
- } catch (InterruptedException var20) {
- this.stop();
- }
- }
- } else {
- this.field_4 -= this.YStep;
- if (this.field_4 < -this.textImageHeight) {
- this.field_4 = this.field_3;
- if (this.pause2 == -1) {
- return;
- }
-
- try {
- Thread.sleep((long)this.pause2);
- } catch (InterruptedException var19) {
- this.stop();
- }
- }
- }
-
- try {
- Thread.sleep((long)this.pause);
- } catch (InterruptedException var18) {
- this.stop();
- }
- } while(this.field_1);
-
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var17) {
- this.stop();
- }
- }
-
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var14) {
- this.stop();
- }
- }
-
- }
-
- public String[] warp(String s, FontMetrics fm) {
- String[] str = null;
- Vector v = new Vector();
- int wi2 = this.field_2 - this.decx - 6;
- int l = 1;
- if (fm.stringWidth(s) >= wi2) {
- int pl = 0;
-
- do {
- int p = s.indexOf(" ", pl + 1);
- if (p == -1) {
- p = s.length();
- }
-
- if (fm.stringWidth(s.substring(0, p)) <= wi2) {
- pl = p;
- } else {
- if (pl == 0) {
- while(true) {
- --p;
- if (fm.stringWidth(s.substring(0, p)) < wi2) {
- v.addElement(s.substring(0, p));
- s = s.substring(p);
- break;
- }
- }
- } else {
- v.addElement(s.substring(0, pl));
- s = s.substring(pl + 1);
- }
-
- ++l;
- pl = 0;
- }
- } while(fm.stringWidth(s) >= wi2);
-
- ++l;
- v.addElement(s);
- } else {
- v.addElement(s);
- }
-
- str = new String[v.size()];
- v.copyInto(str);
- return str;
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- if (this.enterBackColor != null) {
- ((Component)this).setBackground(this.enterBackColor);
- ((Component)this).repaint();
- }
-
- if (this.statusBarText != null) {
- ((Applet)this).showStatus(this.statusBarText);
- }
-
- if (this.enterSound != null) {
- this.enterSound.play();
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(12));
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- if (this.enterBackColor != null) {
- ((Component)this).setBackground(this.backColor);
- ((Component)this).repaint();
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(0));
- }
-
- }
-
- public void mousePressed(MouseEvent e) {
- if (this.clicSound != null) {
- this.clicSound.play();
- }
-
- if (this.freeze) {
- this.field_1 = !this.field_1;
- }
-
- if (this.link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(this.link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- }
-
- public void mouseReleased(MouseEvent e) {
- }
- }
-